package org.flycloud.web.frame.web;

import java.util.List;

import org.flycloud.web.decoupling.RemoteControllerFactory;
import org.flycloud.web.platform.api.IPlatformController;
import org.flycloud.web.platform.entity.Menu;
import org.flycloud.web.sso.common.Token;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttribute;

@Controller
@DependsOn({ "remoteControllerFactory" })
public class PlatformController {

	private IPlatformController platform = (IPlatformController) RemoteControllerFactory
			.getInstance(IPlatformController.class);

	@RequestMapping("/root")
	@ResponseBody
	public List<Menu> getRoots(@SessionAttribute(Token.TOKEN) String token) {
		return platform.menuTree(token);
	}

	@RequestMapping(value = { "/index", "/" })
	public String managerIndex() {
		return "index";
	}

}
